package api.db;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.apache.commons.dbutils.QueryRunner;

public class JDBCUtils {

    private static final QueryRunner queryRunner =
            new QueryRunner(new ComboPooledDataSource());


    private static final QueryRunner queryRunner1 =
            new QueryRunner(new ComboPooledDataSource("mysql1"));


    private static final QueryRunner queryRunner2 =
            new QueryRunner(new ComboPooledDataSource("mysql2"));


    public static final QueryRunner getQueryRunner(String db){
        if("mysql1".equals(db)) {
            return queryRunner1;
        } else if("mysql2".equals(db)){
            return queryRunner2;
        }
        return queryRunner;
    }

    public static final QueryRunner getQueryRunner(){
        return   getQueryRunner("");
    }

    public static final QueryRunner getQueryRunner1(){
      return   getQueryRunner("mysql1");
    }

    public static final QueryRunner getQueryRunner2(){
        return   getQueryRunner("mysql2");
    }
}
